#include "calibrationhalationform.h"
#include "ui_calibrationhalationform.h"
#include <QPainter>
#include <QStyleOption>
#include <QDoubleSpinBox>

CalibrationHalationForm::CalibrationHalationForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CalibrationHalationForm)
{
    ui->setupUi(this);
    this->setFixedHeight(80);
    this->setProperty("form","backgroundform");
    ui->leftBorderForm->SetLabelIcon("halationform");
    ui->leftBorderForm->UpdateShowType(3);

    // 连接滑块的值变化信号到数字输入框的槽函数
    connect(ui->horizontalSlider_halation, &QSlider::valueChanged, this, &CalibrationHalationForm::updateSpinBoxHalation);
    // 连接数字输入框的值变化信号到滑块的槽函数
    connect(ui->doubleSpinBoxHalation, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &CalibrationHalationForm::updateSliderHalation);

}

CalibrationHalationForm::~CalibrationHalationForm()
{
    delete ui;
}

void CalibrationHalationForm::updateSpinBoxHalation(int value)
{
    ui->doubleSpinBoxHalation->setValue(value/ 100.0);
}

void CalibrationHalationForm::updateSliderHalation(double value)
{
    ui->horizontalSlider_halation->setValue(static_cast<int>(value*100));
}


void CalibrationHalationForm::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.init(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget,&opt,&painter,this);
    QWidget::paintEvent(event);
}
